# -*- coding: utf-8 -*-
#
# Copyright 2008 Yejun Yang
#

def dummify_beaker():
    """remove some unavailable functions from beaker"""
    import beaker.synchronization
    dummy = lambda *args, **kwargs: beaker.synchronization.null_synchronizer()
    beaker.synchronization.file_synchronizer = dummy
    beaker.synchronization.mutex_synchronizer = dummy
    beaker.synchronization.NameLock = dummy

    

def secure(handler_method):
    def handle(self, *args):
        if self.is_secure or self.is_dev:
            handler_method(self, *args)
        else:
            import re
            self.redirect(re.sub(r'^http://', r'https://',self.request.url), permanent=True)
    return handle

def etag(handler_method):
    def tag(self, *args):
        pass
    return tag